///
/// ArmyBodger 3
/// (c)2010 richyp
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArmyBodger.Core {
    /// <summary>
    /// Bonus to Attributes, usually provided by equipment
    /// </summary>
    public class Bonus {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="attribute">The attribute name affected</param>
        /// <param name="value">The amount to modify the value by</param>
        /// <param name="type">The type of modification</param>
        public Bonus(string attribute,int value,BonusType type) {
            this.Attribute = attribute;
            this.Value = value;
            this.Type = type;
        }
        /// <summary>
        /// The name of the Attribute affected
        /// </summary>
        public string Attribute { get; set; }
        /// <summary>
        /// The amount to modify the value by
        /// </summary>
        public int Value { get; set; }
        /// <summary>
        /// The modification type, e.g. Add,Subtract etc...
        /// </summary>
        public BonusType Type { get; set; }
        /// <summary>
        /// Get the modified attribute value
        /// </summary>
        /// <param name="value">The original value</param>
        /// <returns>The modified value</returns>
        public int ApplyBonus(int value) {
            switch (this.Type) {
                case BonusType.Add:
                    return value + this.Value;
                case BonusType.Subtract:
                    return value - this.Value;
                case BonusType.Divide:
                    return value / this.Value;
                case BonusType.Multiply:
                    return value * this.Value;
                case BonusType.Set:
                    return this.Value;
            }
            return value;
        }
    }
    /// <summary>
    /// The possible Bonus types
    /// </summary>
    public enum BonusType {
        Add,
        Subtract,
        Multiply,
        Divide,
        Set
    }
}
